import { defineAmisPlugin, getInputTpl } from '../../base/util';
import CommonBusinessCard, { type IProps } from './fc';

export default defineAmisPlugin<IProps>(({ amisEditor }) => {
  const { getSchemaTpl } = amisEditor;

  return {
    component: CommonBusinessCard,
    options: {
      type: 'common-business-card',
      order: 1,
      name: '通用业务卡片',
      icon: 'FileImageOutlined',
      description: '通用业务卡片',
      panelTitle: '通用业务卡片',
      scaffold: {
        mode: 'iframe'
      },
      panelTabs: [
        {
          title: '常规',
          body: [
            getSchemaTpl('collapseGroup', [
              {
                title: '基本',
                body: [
                  {
                    type: 'select',
                    name: 'mode',
                    value: "${mode||''}",
                    options: [{ value: 'iframe', label: 'iframe' }, { value: 'qiankun', label: 'qiankun' }],
                    label: '集成模式',
                  },
                  getInputTpl('src', { label: 'H5地址', visibleOn: "${mode==='iframe'}" }),
                  getInputTpl('microName', { label: '微应用名称', visibleOn: "${mode==='qiankun'}" }),
                  getInputTpl('microEntry', { label: '微应用地址', visibleOn: "${mode==='qiankun'}", placeholder:'/business/test/index.html' }),
                  getInputTpl('microPathname', { label: '微应用路由', visibleOn: "${mode==='qiankun'}" }),
                  getInputTpl('title', { label: '标题' }),
                  getInputTpl('more', { label: '更多文案' }),
                  getInputTpl('moreSrc', { label: '跳转链接' }),
                  getInputTpl('width', { label: '宽度', type: 'number' }),
                  getInputTpl('height', { label: '高度', type: 'number' })
                ],
              }
            ]),
          ],
        },
        {
          title: '外观',
          body: [
            getSchemaTpl('collapseGroup', [
              ...getSchemaTpl('theme:common', { styleName: 'style' }),
            ]),
          ],
        }
      ],
    },
  };
});
